package com.itdfq.resttemplate.controller;

import com.itdfq.resttemplate.entity.HouseInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author GocChin
 * @Date 2021/7/20 10:52
 * @Blog: itdfq.com
 * @QQ: 909256107
 * @Description: 测试Controller
 */
@RestController
@Slf4j
public class HouseController {
    @GetMapping("/house/data")
    public HouseInfo getData(@RequestParam("name") String name) {
        return new HouseInfo(1L, "上海", "虹口", "东体小区");
    }

    @GetMapping("/house/data/{name}")
    public String getData2(@PathVariable("name") String name) {
        return name;
    }

    @RequestMapping(value = "/house/save", method = RequestMethod.POST)
    public HouseInfo getData3(@RequestBody HouseInfo houseInfo) {
        log.info("执行了post请求方法");
        return houseInfo;
    }

    @RequestMapping(value = "/house/save", method = RequestMethod.POST, headers = {"token=123456"})
    public HouseInfo getData4(@RequestBody HouseInfo houseInfo) {
        log.info("执行了post 带heads的方法");
        houseInfo.setCity("海南");
        return houseInfo;
    }



}
